package main

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"log"
	logsystem "logsystem/config"
	"logsystem/service"
	"net"
	"time"
)

var logsystemAddr = flag.Int("logsystemAddr", 16015, "the address to connect to")

func main() {
	fmt.Println(time.Now().Format("2006010215"))
	flag.Parse()
	lis, err := net.Listen("tcp", fmt.Sprintf("logsystem:%d", *logsystemAddr))
	//lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *logsystemAddr))
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	//leaderboard.RegisterProdScoreBoardServiceServer(s, &service.Rank{})
	logsystem.RegisterLogSystemServer(s, &service.LogSystem{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
	/*log.Println("start")
	c := cron.New(cron.WithSeconds())
	spec := "00 * * * * ?"
	_, err = c.AddFunc(spec, database.MigrationDataToMysql)
	if err != nil {
		log.Println(err.Error())
		return
	}
	c.Start()
	defer c.Stop()*/
}
